-
Notifications
You must be signed in to change notification settings - Fork 180
Dynamic message publishers and subscribers #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Dynamic message publishers and subscribers #492
Conversation
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
15f1a9b to
470396b
Compare
|
I've started using this pull request in one of my projects and I have noticed an issue with messages containing sequences of messages (for instance test_msgs/msg/UnboundedSequences). The program panics when trying to access an empty sequence of messages. To reproduce: let message_type = MessageTypeName {
package_name: "test_msgs".to_owned(),
type_name: "UnboundedSequences".to_owned(),
};
let mut msg = DynamicMessage::new(message_type).unwrap();
let value = msg.get("basic_types_values");In |
This reminds me of #407. |
Signed-off-by: Luca Della Vedova <[email protected]>
|
Hello, hope this is working well for you! I fixed the panic for both mutable and non mutable access and added (+ expanded) your snippet as a regression test in e21a4a7, let me know if it works for you :) |
Signed-off-by: Luca Della Vedova <[email protected]>
|
Thank you for the quick fix. It's working now |
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
|
@luca-della-vedova I've fixed the remaining conflict, but let's see if CI works. I'm happy to take it from here, I used to have a branch with Nikolai's changes fleshed out and would like to get this merged for the next release. |
|
@luca-della-vedova BTW, I'll get rid of the |
|
@esteve I saw that you opened #551 and I have to admit I'm not really happy with this way to proceed. In my view, the process for contributions should be:
Since this PR was opened about 5 months ago I only received one comment about a panic and addressed it within 24h, so in my opinion forking the PR is not really justified right now.
|
|
@luca-della-vedova sorry, I didn't mean to offend you, I really appreciate all the work you did. I opened the other PR to trigger the CI because I couldn't push here, and then got so into it that started hacking on stuff to get the CI passing, but I'm happy to submit a PR to your branch and continue the discussion here. Again, sorry this caused any bad feelings. |
|
@luca-della-vedova I think the two first points are addressed/discussed and that we're in agreement. Regarding the third point, it's not that it's hacky or overengineered, I think it's useful, but lazy_cell, which LazyLock depends on, was only made stable in Rust 1.80 and since CI is targeting 1.75, I reverted to get the CI to pass. |
If this is the only blocker, it should be possible to replace all uses of pub static DYNAMIC_MESSAGE_PACKAGE_CACHE: LazyLock<Mutex<DynamicMessageLibraryCache>> =
LazyLock::new(|| Default::default());we would need to have pub fn get_dynamic_message_package_cache() -> &'static Mutex<DynamicMessageLibraryCache> {
static DYNAMIC_MESSAGE_PACKAGE_CACHE: OnceLock<Mutex<DynamicMessageLibraryCache>> = OnceLock::new();
DYNAMIC_MESSAGE_PACKAGE_CACHE.get_or_init(|| Default::default())
}Then wherever we would've called DYNAMIC_MESSAGE_PACKAGE_CACHE.lock().unwrap()we instead call get_dynamic_message_package_cache().lock().unwrap() |
|
@mxgrey that works for me. @luca-della-vedova thoughts? |
|
That's odd, I enabled the "allow edits from maintainers", and it seems that a few weeks ago you managed to push a "merge to main" into this branch (8cf5ce0)? |
I merged that two days ago via the website. But now I realize what happened, I checked out your branch before I did the merge with main, clicked merge and then the branches diverged. And instead of actually reading the error message when I did Anyway, this was an example of Hanlon's razor, so in the end it was my fault for not carefully reading the error message from GitHub, but there was no malice at all 🙂
Sounds good to me, whatever is easier to you.
I saw it in the logs of the other PR, and then found about |
Signed-off-by: Luca Della Vedova <[email protected]>
|
I think I found out why I didn't see the issue with 1.75. I use a newer version locally and the CI isn't actually doing anything. |
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Luca Della Vedova <[email protected]>
This PR revives #262 from @nnmm (as evident from the first commit that actually does 95% of the work!), with a few minor updates:
I'll admit that most of the code under
field_access(where the casting and reinterpreting of arbitrary messages is done) is a bit out of my comfort zone, however loopback tests, message serialization and deserialization seem to work so it is at least doing something sensible.Following the initial implementation this is all under a
dyn_msgfeature flag, but I'm not 100% convinced that the additional[cfg(feature = "dyn_msg")]directives that are scattered throughout the codebase are worth it. Specifically on my (very overpowered) machine a clean build withdyn_msgenabled builds a total of 93 packages while a clean build without the feature builds 89 packages. The compile time difference itself is hard to detect.Originally, the PR was split into a separate one that only included the message structure. I'm happy to split this into smaller chunks if that makes it easier to review but I thought I would show what a full implementation looks like first.
This only tackles messages, publishers and subscribers. Services (and actions) are left as a future implementation.